import { detailApi } from "@/api/api";

// 详情模块
const detailModule = {
  namespaced: true,
  state() {
    return {
      // 详情数据
      detailData: {},
    };
  },
  mutations: {
    // 改变详情数据
    getDetailData(state, payload) {
      state.detailData = payload.result;
    },
  },
  actions: {
    // 异步获取详情数据
    async asyncGetDetailData({ commit }, payload) {
      const res = await detailApi({ id: payload.id });
      commit("getDetailData", res);
    },
  },
};

export default detailModule;
